<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.Iterator"%>
<%@ page import="com.docman.domainmodel.*;" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>DocMan Profil</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<style type="text/css">
	table.profileInfo {clear: both}
	table.profileInfo th {width: 25%}
	table.profileInfo th p {color: red; text-align:center; font-weight: bold}
	table.profileInfo td {width: 35%}
	table.uploads th {width:20%; line-height: 2em; background-color: #696265; color: white}
	table.uploads td {width:20%}
	#profileLink a{background-color: #5481E3; text-align: center}
</style>

<link rel="stylesheet" type="text/css" href="js/jRating/jRating.jquery.css" media="screen" />
<script type="text/javascript" src="js/jRating/jquery.js"></script>
<script type="text/javascript" src="js/jRating/jRating.jquery.js"></script>

<script type="text/javascript">
  $(document).ready(function(){
    $(".rating").jRating({
	  length : 5, // nb of stars
	  decimalLength : 2, // number of decimal in the rate
	  canRateAgain : false,
	  rateMax :5,
	  isDisabled:true,
	  step:false
    });
  });
</script>


</head>
<body>

<div id="main_container">
	<div id="header">
			<div class="logo"><a href="index.jsp"><img src="img/top.png" border="0" alt="" title="" /></a></div>       
	</div>
        <div class="menu">
        	<ul>                                                                         
        		<li><a href="index.jsp">Anasayfa</a></li>
                <li class="selected"><a href="#">Profil</a></li>
                <li><a href="getTagServletpath?sId=0">Dosya Yükleme</a></li>
                <li><a href="getTagServletpath?sId=1">Ayrıntılı arama</a></li>
                <li><a href="contract.jsp">İletişim</a></li>
                <% if(session.getAttribute("currentSessionUser")!= null){ 
                 UserBean user = (UserBean)session.getAttribute("currentSessionUser");%>
                <li><a href="logout.jsp">Çıkış <span style="color: red;">(<span style="font-weight: bold;
                     text-decoration: underline"><%= user.getUserName() %></span>)</span></a></li>
                <% } else { %>
                <li><a href="getUniandDeptServletpath">Kaydol</a></li>
                <% } %>
        	</ul>
        </div>
        
    <div class="center_content">
        <% if(session.getAttribute("currentSessionUser")!= null){ 
        UserBean user = (UserBean)(session.getAttribute("currentSessionUser"));
        ArrayList<DocumentBean> docs = (ArrayList<DocumentBean>)request.getAttribute("userDocList"); %> 
        
      
        	<a href="changePassword.jsp"><button style="color: white; font-weight: bold" class="button">Şifre Değiştirme</button></a>      	
        
        	<fieldset style="margin-left:45em">
			<form action="searchServletpath" method="post">      	
        		<table style="width: 0em">
        			<tr>
        				<td style="font-size:120%; color:#5481E3; font-weight: bold">Dosya Arama:</td>
        			</tr>
        			<tr>
        				<td><input type="text" name="search" size="20"/></td>
        				<td><input type="submit" name="submit" class="button" value="Ara" /></td>
        			</tr>
        		</table>        	
        	</form>
        	</fieldset>
		<br />
		<hr />
        <center>
        <h2 style="color: #5481E3; text-decoration: underline">Profiliniz</h2>
        <table class="profileInfo" cellpadding="1.2em" cellspacing="1.2em" width="60%" border="1">
        	<tr>
        		<th><p>Kullanıcı Adı:</p></th>
        		<td><%= user.getUserName() %></td>
        	</tr>
        	<tr>
        		<th><p>Adı:</p></th>
        		<td><%= user.getFirstName() %></td>
        	</tr>
        	<tr>
        		<th><p>Soyadı:</p></th>
        		<td><%= user.getLastName() %></td>
        	</tr>
        	<tr>
        		<th><p>E-mail:</p></th>
        		<td><%= user.getEmail() %></td>
        	</tr>
        	<tr>
        		<th><p>Üniversite:</p></th>
        		<td><%= user.getUniversity().getUniversityName() %></td>
        	</tr>
        	<tr>
        		<th><p>Bölüm:</p></th>
        		<td><%= user.getDepartment().getDepartmentName() %></td>
        	</tr>
        	<tr>
        		<th><p>Gizli Soru:</p></th>
        		<td><%= user.getQuestion() %></td>
        	</tr>
        	<tr>
        		<th><p>Cevap:</p></th>
        		<td><%= user.getAnswer() %></td>
        	</tr>
        	
        </table>
        <hr />
        <center><h2 style="color: #5481E3; text-decoration: underline">Yüklenen Dosyalar</h2></center>
        <table class="uploads" cellpadding="1.2em" cellspacing="1.2em" width="80%" border="1">
        	<tr>
        		<th>Dosya Adı</th>
        		<th>Kategori</th>
        		<th>Yüklenme Tarihi</th>
        		<th>Aldığı Oy</th>
        		<th>Dosya Sil</th>
        	</tr>
        	<% 
        		for(int i=0;i<docs.size();i++){%>
        				<tr>
        		 		<td><%= docs.get(i).getTitle() %></td>
        		 		<td><%= docs.get(i).getTag() %></td>
        		 		<td><%= docs.get(i).getUploadDate() %></td>
        		 		<%double avg =0; 
        		 		if(docs.get(i).getRatingCount()==0){
        		 			avg = 0;
        		 			}
        		 			else
        		 			avg =docs.get(i).getRating()/docs.get(i).getRatingCount();
        		 		 %>
         				<td><div class="rating" data-average="<%=avg%>" data-id="" style="width: 2em; height: 1em; overflow: hidden; z-index: 1; position: relative; cursor: default;"></div></td></td>
         				<td><form action="deleteFileServletpath" method="post">
         					<input type="hidden" name="link" value="<%= docs.get(i).getDocName() %>" />
          				<button type="submit" name="submit" value="Sil" class="button" width="8px">Sil</button></a>
       					</form></td>
       					</tr>
       				<% } %>
        </table>
        
        </center>           
		<% }else { %>
		<p style="font-size: 1.5em; text-align: center;color:red">Lütfen <a href="index.jsp">Anasayfa</a>'dan giriş yapınız.  </p>	
		<p style="font-size: 1.5em; text-align: center;color:red">Veya menüden Kaydol butonuna tıklayıp sitemize üye olabilirsiniz. </p>
		<% } %>
    </div>
         
</div>

</body>
</html>